/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine - graphics/scene
// Copyright (c) 2014.  All Rights Reserved
//
// File:		AECamera.h
// Author:		Gianluca Belardelli
// Date:		10/06/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AECAMERA_H_
#define _AECAMERA_H_

/// \brief
///   Class for setting cameras for invidual render contexts
/// The VisCameraContext_cl class provides functionality to create and handle cameras. Each context
/// camera has to be attached to one or more render contexts in order to take effect. See the
/// VisRenderContext_cl class as a reference. You can either attach the camera to an existing
/// VisObject3D_cl (e.g. entity) or set the camera position and orientation manually.
class AECamera : public AE3DObject
{
// Methods
public:
	/// \brief Default Constructor for the VisContextCamera_cl class
	AE_DLLIMPEXP AECamera( void );
	
	/// \brief Destructor for the VisContextCamera_cl class
	AE_DLLIMPEXP virtual ~AECamera( void );
	
	/// \brief Sets the position and orientation of the context camera in world-space.
	/// \param cameraMatrix Rotation of the camera in world-space.
	/// \param position Position of the camera in world space.
	AE_DLLIMPEXP void Set( const AEMatrix3f &mtCameraMatrix, const AEVector4f &vcPosition );  
	AE_DLLIMPEXP void Set( const AEMatrix4f &mtCameraMatrix );
	/// \brief Attaches the camera to a specific entity.
	/// It also sets a position and orientation
	/// relative to the entity which will be used to calculate the final position of the camera.
	/// Internally, this function uses the AttachToParent, SetLocalPosition and SetLocalOrientation
	/// methods exposed by the VisObject3D_cl class.
	/// \param entity entity to which the camera will be attached
	/// \param spawnPos position relative to the entity's origin
	/// \param rotationMatrix orientation relative to the entity's orientation
	//AE_DLLIMPEXP void AttachToEntity(VisBaseEntity_cl *entity, const AEVector3f& spawnPos, const AEMatrix3f* rotationMatrix = NULL);
	
	/// \brief Returns the direction of the camera
	/// This function returns the current world space direction of the camera
	/// The view direction is a normalized vector in world space.
	/// \return AEVector3f& direction: current camera direction vector
	AE_DLLIMPEXP const AEVector4f GetDirection( void ) const;
	
	/// \brief Returns the visibility zone the camera is currently in.
	//AE_DLLIMPEXP VisVisibilityZone_cl *GetVisibilityZone() const;
	
	/// \brief Returns whether this context camera is the currently active camera
	/// \return AEBOOL32 bActive: TRUE if this context camera is the currently active camera
	AE_DLLIMPEXP AEBOOL32 IsActive( void ) const;
	
	/// \brief Updates the camera matrix. Must be called by before the scene is rendered.
	AE_DLLIMPEXP void Update( void );
	
	/// \brief Gets the current 3x3 rotation matrix that rotates direction vectors from camera space to world space.
	AE_DLLIMPEXP AEMatrix3f GetCameraToWorldRotation( void ) const;
	
	/// \brief Gets the current 3x3 rotation matrix that rotates direction vectors from world space to camera space.
	AE_DLLIMPEXP AEMatrix3f GetWorldToCameraRotation( void ) const;
	
	/// \brief Gets the current 4x4 transformation matrix that transforms points from camera space to world space.
	AE_DLLIMPEXP AEMatrix4f GetCameraToWorldTransformation( void ) const;
	
	/// \brief Gets the current 4x4 transformation matrix that transforms points from world space to camera space.
	AE_DLLIMPEXP AEMatrix4f GetWorldToCameraTransformation( void ) const;
};

typedef AESmartPtr<AECamera> AECameraPtr;

#endif // _AECAMERA_H_
